<?php
namespace Home\Model;
use Think\Model\RelationModel;


class SchoolModel extends RelationModel
{
    protected $_link  = 
           array(    

           'SchoolRelation' => array(   
            'mapping_type'  => self::HAS_MANY,  
            'class_name'    => 'SchoolRelationView',  
            'foreign_key'   => 'school_id', 

           // 'mapping_name'  => 'dept', 
            ),
           'SchoolAddress' => array(   
            'mapping_type'  => self::HAS_ONE,  
            'class_name'    => 'SchoolAddress',  
            'foreign_key'   => 'school_id',
            'condition' 	=>'main=1',  
           // 'mapping_name'  => 'dept', 
            ),

                   );
    /*
     *  显示本学校问题 
     * 
     * 
     *          */

    public function ask_show($school_id) {
        $ask = M('SchoolAsk');
        $map['school_id'] = $school_id;
        $map['state'] = 1;
        $list = $ask->where($map)->order('timeadd desc')->limit(0, 4)->select();
        return $list;
//        ;
    }


}